﻿using System.Configuration;

namespace LaserTag.Infrastructure.Configuration
{
    public class VideoCaptureSettingsSection : ConfigurationSection
    {
        public const string ConfigurationSectionName = "VideoCaptureSettings";
        [ConfigurationProperty("VideoDevice")]
        public VideoDeviceConfigCollection DeviceItems
        {
            get { return ((VideoDeviceConfigCollection)(base["VideoDevice"])); }
        }
    }

    [ConfigurationCollection(typeof(VideoDeviceConfigurationElement))]
    public class VideoDeviceConfigCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new VideoDeviceConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((VideoDeviceConfigurationElement)(element)).DeviceMoniker;
        }

        public VideoDeviceConfigurationElement this[int idx]
        {
            get
            {
                return (VideoDeviceConfigurationElement)BaseGet(idx);
            }
        }
    }

    public class VideoDeviceConfigurationElement : ConfigurationElement
    {
        [ConfigurationProperty("deviceMoniker", DefaultValue = "", IsKey = true, IsRequired = false)]
        public string DeviceMoniker
        {
            get
            {
                return ((string)(base["deviceMoniker"]));
            }
            set
            {
                base["deviceMoniker"] = value;
            }
        }

        [ConfigurationProperty("videoWidth", DefaultValue = 320, IsKey = false, IsRequired = false)]
        public int VideoWidth
        {
            get
            {
                return ((int)(base["videoWidth"]));
            }
            set
            {
                base["videoWidth"] = value;
            }
        }
        
        [ConfigurationProperty("videoHeight", DefaultValue = 240, IsKey = false, IsRequired = false)]
        public int VideoHeight
        {
            get
            {
                return ((int)(base["videoHeight"]));
            }
            set
            {
                base["videoHeight"] = value;
            }
        }

        [ConfigurationProperty("fps", DefaultValue = 30, IsKey = false, IsRequired = false)]
        public int Fps
        {
            get
            {
                return ((int)(base["fps"]));
            }
            set
            {
                base["fps"] = value;
            }
        }
    }
}
